#include <fstream>
#include "Newton.h"
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;

int main()
{


  double n;
  for (n=5;n<=20;n=n+5)
    {
      vector<double> x;
      vector<double> y;
      for(int i=0;i<n;i++){
      x.push_back(10);
      y.push_back(10);
 }
 
  for (int i=1;i<=n;i++)
    {
      x[i-1]=cos((2*i-1)/(2*n)*M_PI);
    }
  for (int i=0;i<n;i++)
    {
      y[i]=1/(1+25*x[i]*x[i]);
    }

 Newton problem_c(x,y);
 cout<<"When N equals "<<n<<":"<<endl;
 for(int i=0;i<x.size();i++){
 cout<<"x^("<<n-1-i<<"): "<<problem_c.answer[i]<<endl;
 }
    

 
    ofstream p_C;
    if(n==5) p_C.open("p_C.txt", std::ios::out);
    else p_C.open("p_C.txt", std::ios::out | std::ios::app);  
       if (!p_C.is_open())
        return 0;
            for(int i=0;i<x.size();i++)
	      {
               p_C<< problem_c.answer[i] <<endl;
              }

	      p_C.close();
    }
}
